package com.cy.wenxinapi.util;

import com.github.pagehelper.PageInfo;

import java.util.List;

public class PageUtils {
    /**
     * 将分页信息封装到统一的接口
     * @param list
     * @return
     */
    public static <T> Page getPageResult(List<T> list) {
        PageInfo<T> pageInfo = new PageInfo<>(list);
        Page page = new Page();
        page.setPageNo(pageInfo.getPageNum());
        page.setPageSize(pageInfo.getPageSize());
        page.setTotalSize(pageInfo.getTotal());
        page.setTotalPages(pageInfo.getPages());
        page.setData(pageInfo.getList());
        return page;
    }
}
